home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Leonardo the Inventor
/
Leonardo The Inventor (93026)(Broderbund)(Riverdeep)(2004).iso
/
LEOWINMV
/
DATABASE.DIR
/
00106_Script_CHECK DATABASE - LINKS
< prev
next >
Wrap
Text File
|
1996-03-28
|
3KB
|
91 lines
-- --------------------------------------------------------------
-- Handler getLinks finds all the hypertext links in the given
-- casts and stores them in the field "hyperText links"
on getLinks firstCast, lastCast, linkStyle, linkColor
-- empty the field for the new generation
put EMPTY into field "hyperText Links"
-- go through every cast from firstCast to lastCast
repeat with currentCast = firstCast to lastCast
set curArticle = the name of cast currentCast
put "checking links in cast" && currentCast && "," && curArticle
set numWords = the number of words in field currentCast
set curWordNum = 1
-- go through every word in the current cast.
repeat while (curWordNum <= numWords)
-- get the style and color of the current word
set curWord = word curWordNum of field currentCast
set curStyle = the textStyle of word curWordNum of field currentCast
set curColor = the foreColor of word curWordNum of field currentCast
set hyperphrase = EMPTY
-- if the current word is part of a hypertext phrase, the following
-- repeat loop will be executed.
repeat while (curColor = linkColor) and (curStyle = linkStyle) then
-- found a hypertext word
-- get the whole hypertext phrase, and update curWordNum
put "found a hypertext link in cast" && currentCast && "," && curArticle
set hyperphrase = hyperphrase & word curWordNum of field currentCast
set curWordNum = curWordNum + 1
-- get the style and color of the next word
set curStyle = the textStyle of word curWordNum of field currentCast
set curColor = the foreColor of word curWordNum of field currentCast
end repeat -- end of hypertext phrase reached
if (hyperphrase <> EMPTY) then
put curArticle & ":" & hyperphrase & RETURN after field "hyperText Links"
end if
set curWordNum = curWordNum + 1
end repeat -- going through all words in cast currentCast
end repeat -- going through all casts
end
-- --------------------------------------------------------------
-- Handler checkLinks checks all the links in field "hyperText links"
on checkLinks
-- empty the field for the new generation
put EMPTY into field "hyperText Errors"
initalizeEquivalentTerms
set linkInfo = field "hyperText Links"
set numLinks = the number of lines in linkInfo
-- go through all the links
repeat with i = 1 to numLinks
put "checking" && i && "of" && numlinks
-- keep setting the itemDelimiter because it is reset in getEquivalentTerm
set the itemDelimiter = ":"
set originalCast = item 1 of line i of linkInfo
set curLink = item 2 of line i of linkInfo
-- check if the phrase ends with punctuation
repeat while(endsWithPunctuation(curLink))
set curLink = removePunctuationFromEnd(curLink)
end repeat
-- go through the current link
set linkCast = the number of cast (curLink && "TEXT1")
if (linkCast = -1) then
-- check if an equivalent term exists
set equivTerm = getEquivalentTerm(curLink)
if (equivTerm = -1) then
-- hypertext error
put originalCast & ":" & curLink & RETURN after field "hyperText Errors"
end if
end if
end repeat
set the itemDelimiter = ","
end